package middleware

import (
	"github.com/gin-gonic/gin"
	"github.com/prometheus/client_golang/prometheus"
)

var uriRequestCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
	Namespace: "im",
	Subsystem: "api",
	Name:      "request",
	Help:      "Total number of api request",
}, []string{"method", "uri"})

func RegisterPrometheus() {
	prometheus.Register(uriRequestCounter)
}
func PrometheusMiddleware(ctx *gin.Context) {
	uriRequestCounter.WithLabelValues(ctx.Request.Method, ctx.Request.URL.Path).Inc()
}
